<?php echo $this->render("header.phtml"); ?>
<label class="title">Add a new article</label>
<div class="horiz_sep">&nbsp;</div>
<?php
	$baseUrl  = $this->baseUrl;
	$contextPath = $this->contextPath;
	$article  = $this->article;
	$errors = $this->errors;
?>
<form action="<?= $baseUrl ?>/<?= $contextPath ?>/add-article" method="post" enctype="multipart/form-data">
<table cellpadding="5" cellspacing="0" width="100%" border="0">
	<?php if (count($errors)){ ?>
	<tr>
		<td>
			<? 
				if (key_exists('title_null', $errors)) $title_null = $errors['title_null'];
				else $title_null = "";
				if (key_exists('content_null', $errors)) $content_null = $errors['content_null'];
				else $content_null = "";
			?>
			<font color="red" style="font-weight:bold;">
				<? if (strlen($title_null)) echo "<p> * ".$title_null."</p>"; ?>
				<? if (strlen($content_null)) echo "<p> * ".$content_null."</p>"; ?>
			</font>
		</td>
	</tr>
	<?php } ?>
	<tr>
		<td>
			<table cellpadding="0" cellspacing="0" border="0" width="100%">
				<tr>
					<td>
						<b>Title: <font color="red">*</font></b>
					</td>
				</tr>
				<tr>
					<td>
						<input maxlength="200" type="text" name="article_title" value="<?= $article['art_title'] ?>" style="width:100%; padding:2px;"/>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td>
			<table cellpadding="0" cellspacing="0" border="0" width="100%">
				<tr>
					<td>
						<b>Description:</b>
					</td>
				</tr>
				
				<tr>
					<td>
						<textarea name="article_lead" style="width:100%; font-size: 9pt;" rows="5"><?= $article['art_lead'] ?></textarea>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td>
			<table cellpadding="0" cellspacing="0" border="0" width="100%">
				<tr>
					<td>
						<b>Content: <font color="red">*</font></b>
					</td>
				</tr>
				<tr>
					<td>
					<textarea name="article_content" rows="5" style="width:100%;"><?= $article['art_content'] ?></textarea>
						<script src="<?= $baseUrl ?>/public/scripts/fckeditor/fckeditor.js" type="text/javascript"></script>	
						<script type="text/javascript">
							<!--
							// Automatically calculates the editor base path based on the _samples directory.
							// This is usefull only for these samples. A real application should use something like this:
							// oFCKeditor.BasePath = '/fckeditor/' ;	// '/fckeditor/' is the default value.
							var sBasePath = '<?= $baseUrl ?>/public/scripts/fckeditor/' ;
							var oFCKeditor = new FCKeditor( 'article_content' ) ;
							oFCKeditor.BasePath	= sBasePath ;
							oFCKeditor.Height	= 300 ;
							oFCKeditor.ReplaceTextarea() ;
							//-->
						</script>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td>
			<table cellpadding="0" cellspacing="0" border="0" width="100%">
				<tr>
					<td width="7%">
						<b>Image</b>
					</td>					
					<td>
						<input type="file" name="image_file" />
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td>
			<table cellpadding="0" cellspacing="0" border="0" width="100%">
				<tr>
					<td width="7%">
						Published
					</td>					
					<td>
					<?php 
						if ($article['art_published']) $checked = "checked";
						else $checked = "";
					?>
						<input type="checkbox" name="published" value="1" <?= $checked ?>/>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td>
			<input type="submit" name="save" value="Save"/>
		</td>
	</tr>
</table>
</form>
<?php echo $this->render("footer.phtml"); ?>